package com.rayo.accesscontrollercopy.config;


import com.rayo.accesscontrollercopy.model.db.bean.DmuTimeData;
import com.rayo.accesscontrollercopy.model.db.dao.DmuTimeDao;
import com.rayo.accesscontrollercopy.model.db.dao.DmuTimeImpl;
import com.rayo.accesscontrollercopy.model.db.dao.SiteDao;
import com.rayo.accesscontrollercopy.model.db.dao.SiteImpl;

import java.util.List;

/**
 * Created by yanghaojie on 2017/3/9.
 */

public class OfficeModeConfig {
    public static final int STANDAR_MODE = 1;
    public static final int OFFICE_MODE = 2;
    public static final int ON_OFF_MODE = 3;
    public static final int TIME_ON_OFF_MODE = 4;

    private volatile static OfficeModeConfig uniqueInstance;
    private DmuTimeDao mDmuTimeDao = new DmuTimeImpl();
    private SiteDao mSiteDao = new SiteImpl();

    private List<DmuTimeData> mDmuTimeDatas;
    private int mOfficeMode;

    public static OfficeModeConfig getInstance() {
        if (uniqueInstance == null) {
            synchronized (OfficeModeConfig.class) {
                if (uniqueInstance == null) {
                    uniqueInstance = new OfficeModeConfig();
                }
            }
        }
        return uniqueInstance;
    }

    public OfficeModeConfig() {
        this.mDmuTimeDatas = mDmuTimeDao.findAll();
        this.mOfficeMode = mSiteDao.findFirst().getMode();
    }

    public void init() {
        this.mDmuTimeDatas = mDmuTimeDao.findAll();
        this.mOfficeMode = mSiteDao.findFirst().getMode();
    }

    public List<DmuTimeData> getDmuTimeDatas() {
        return mDmuTimeDatas;
    }

    public void setDmuTimeDatas(List<DmuTimeData> dmuTimeDatas) {
        mDmuTimeDatas = dmuTimeDatas;
    }

    public int getOfficeMode() {
        return mOfficeMode;
    }

    public void setOfficeMode(int officeMode) {
        mOfficeMode = officeMode;
    }
}
